#!/usr/sbin/rsct/perl5/bin/perl
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
#  
#  
# Licensed Materials - Property of IBM 
#  
# (C) COPYRIGHT International Business Machines Corp. 2000,2002 
# All Rights Reserved 
#  
# US Government Users Restricted Rights - Use, duplication or 
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp. 
#  
# IBM_PROLOG_END_TAG 

# Display a message to a particular X display about an ERRM event
# that occurred.

# @(#)32   1.3   src/rsct/rm/ER/displayevent.perl, ERrm, rsct_rpyxh, rpyxht1f3 9/3/02 15:28:33

use strict;
use Getopt::Std;
use POSIX qw(strftime);

sub usage {
#------------------------- Put Print Text Up To Here ------------------------->|
print <<ENDOFUSAGETEXT;
Usage:  displayevent [-h] Xdisplay
          -h        Display this usage information.
ENDOFUSAGETEXT
exit 1; }

# Parse the cmd line args and check them
if (! getopts('h') ) { &usage; }
if (scalar(@ARGV) != 1 || $::opt_h) { &usage; }

my ($eventSec,$junk) = split( /,/,$ENV{ERRM_TIME} );
my $convertedTime = strftime("%A %D %T", localtime($eventSec) );

my $str = "$ENV{ERRM_COND_SEVERITY} $ENV{ERRM_TYPE} occurred:\n  Condition:  $ENV{ERRM_COND_NAME}\n  Node:  $ENV{ERRM_NODE_NAME}\n  Resource:  $ENV{ERRM_RSRC_NAME}\n  Resource Class:  $ENV{ERRM_RSRC_CLASS_NAME}\n  Resource Attribute: $ENV{ERRM_ATTR_NAME}\n  Attribute Type: $ENV{ERRM_DATA_TYPE}\n  Attribute Value: $ENV{ERRM_VALUE}\n  Time: $convertedTime\n";

$ENV{'DISPLAY'} = $ARGV[0];

my $rc = system(qq(echo "$str" | gless)) >> 8;

exit $rc;
